📚 SAP Business One SDK Help

Adding a User Field
See Also

Description

The following example shows how to add a User Field to an existing user table.
'Adding a User Field to an existing user table
Private Sub CmdAddField_Click()
    Dim RetVal As Long
    Dim ErrCode As Long
    Dim ErrMsg As String
    Dim UFld As SAPbobsCOM.UserFieldsMD

    Set UFld = vCmp.GetBusinessObject(oUserFields)
    'Set Values to the properties
    UFld.TableName = "TBL1"
    UFld.Name = "MyFld"
    UFld.Description = "My Field"
    UFld.Type = db_Alpha
    UFld.Size = 10
    RetVal = UFld.Add
    If RetVal <> 0 Then
        vCmp.GetLastError ErrCode, ErrMsg
        MsgBox "Failed to add UserField " & ErrCode & " " & ErrMsg
    End If
End Sub